//
//  FIRequestInterfaceActive.m
//  Magpie
//
//  Created by 100TV protocal on 12-11-15.
//
//

#import "FIRequestInterfaceActive.h"
#import "FIHttpAPIHelper.h"
#import "FIStringHelper.h"
#import "SBJSON.h"

@implementation FIRequestInterfaceActive
-(NSString *) uid{
	return [self attributeForKey:@"uid"];
}
-(void) setUid:(NSString *) aUid{
	[self setAttribute:aUid forKey:@"uid"];
}
@end


@implementation FIInterfaceActiveRequset
-(id) initWithInterface: (id)atarget action:(SEL)aaction{
	self=[super initWithTarget:atarget action:aaction];
	if(self!=nil){
		NSString* lang=[[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];
		NSString* appver = appVer();
		[self setParam:@"ipad" forKey:@"platformn"];
		[self setParam:appver forKey:@"clientv"];
		[self setParam:[[UIDevice currentDevice] model] forKey:@"model"];
		[self setParam:[[UIDevice currentDevice] uniqueIdentifier] forKey:@"imei"];
		[self setParam:sourceId() forKey:@"source"];
		[self setParam:stringOrEmpty(lang) forKey:@"language"];
		[self setParam:carrierName() forKey:@"cn_operator"];
	}
	return self;
}
-(void) internalInit{
	self.url = urlWithPath(@"/statistics/active");
}
-(id) parseResponse:(id)response {
	validResponse(response);
	id json = [response JSONValue];
	FIRequestInterfaceActive *ret = [[FIRequestInterfaceActive alloc] init];
	id activeList = [json objectForKey:@"success_response" ] ;
	
	ret.uid = [activeList objectForKey:@"uid"];
	//!! NSLog(@"UID%@",ret.uid);
	return [ret autorelease];
}
@end





